import React from 'react';
// import DragM from 'dragm';
import {Modal} from 'antd';
import PropTypes from 'prop-types';
class ModalTitle extends React.PureComponent {
    componentDidMount() {
        this.modalDom = document.getElementsByClassName('ant-modal-wrap')[0];
    }
    updateTransform = transformStr => {
        this.modalDom.style.transform = transformStr;
    }
    render() {
        const {title} = this.props;
        return (
            // <DragM updateTransform={this.updateTransform}>
                <div>{title}</div>
            // </DragM>
        );
    }
}

ModalTitle.propTypes = {
    title: PropTypes.string
};
// eslint-disable-next-line react/prefer-stateless-function
class SeniorModal extends React.PureComponent {
    render() {
        const {
            zIndex,
            children,
            title,
            width,
            maskClosable,
            onCancel, ...otherProps
        } = this.props;
        const modalTitle = <ModalTitle title={title} />;
        return (
            <Modal
                zIndex={zIndex}
                width={width}
                {...this.props}
                title={modalTitle}
                {...otherProps}
                centered={true}
                maskClosable={maskClosable}
                onCancel={onCancel}>
                <div>
                    {children}
                </div>
            </Modal>
        );
    }
}

SeniorModal.propTypes = {
    maskClosable: PropTypes.bool,
    title: PropTypes.string,
    width: PropTypes.string,
    zIndex: PropTypes.number,
    onCancel: PropTypes.func,
    /**
     * @param title
     */
    onChange: PropTypes.func,
};
SeniorModal.defaultProps = {
    width: '60%',
    zIndex: 999,
    changeOnSelect: true,
    maskClosable: true
};
export default SeniorModal;
